#pragma once
#include "..\ViewBase\ctabctrlez.h"

struct ImageTemplate
{
	enum ImgFormat
	{
		IMF_COLOR,
		IMF_BITMAP,
	};
	ZeroInit(ImageTemplate)
	int ImgType;
	union
	{
		struct
		{
			DWORD BkgColor;
			DWORD FrameColor;
			int Alpha;
		};
		struct
		{
			Image* Image;
			int Alpha;
		};
	};
};

struct LabelItem
{
	ZeroInitR(LabelItem,Rect)
	CStringW Caption;
	CRect Rect;
	CWnd* Window;
};

struct LabelList
{
	ZeroInitR(LabelList,Selected)
	vector<LabelItem*> Item;
	int Selected;
};

struct LabelMeta
{
	enum LabelFormat
	{
		LBF_VERTICAL,
		LBF_HORIZON,
	};
	ZeroInit(LabelMeta)
	int X;
	int Y;
	int Format;
	int Width;
	int Height;
	int Spacing;
	int MaxLabel;
};

class CPicTabLeftPane:public CWnd
{
public:
	CPicTabLeftPane();
	~CPicTabLeftPane();
	int ConstructView(CWnd* Parent,CRect* Rect,DWORD Style);
public:
	void AdjustForLabel();
	void OnItemSelected(int Index);
	vector<LabelItem*> m_vctLabel;
	
	ImageTemplate m_ImgBkg;
	ImageTemplate m_ImgChecked;
	ImageTemplate m_ImgHover;

	CDC m_DCBuffer;
	CBitmap m_DCBitmap;
//simple member
	int m_ID;
	int m_Hover,m_PreHover;
	int m_Chked,m_PreChked;
	TRACKMOUSEEVENT m_MouseMon;
public:
	DECLARE_MESSAGE_MAP()
	afx_msg void OnPaint();
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnMouseLeave();
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
};


class CPicTabCtrl :
	public CTabCtrlEz
{
public:
	CPicTabCtrl(void);
	~CPicTabCtrl(void);
	
public:
	void SetMeta(int X,int Y,int Format,int Width,int Height,int Spacing,int MaxLabel);
	void SetImage(ImageTemplate ImgBkg,ImageTemplate ImgChecked,ImageTemplate ImgHover);
	void AddTab(LPCWSTR Caption);
	void AddLabel(int TabIndex,LPCWSTR Caption,CWnd* BindWnd);
	void OnDraw(CDC* pDC,CRect* Rect);
	int GetCurSel();
	int GetItemCount();
	CWnd* GetItem(int Index);

	vector<LabelList*> m_vctLabelGroup;
	CPicTabLeftPane m_LeftPane;
	LabelMeta m_Meta;
	
//simple member
	int m_HisTabIndex;
	int m_HisLabelIndex;
	MDC* m_MemDC;
	
	
private:
	int AddTab(LPCWSTR Caption,CWnd* BindWnd);

	DECLARE_MESSAGE_MAP()
public:
	afx_msg LRESULT OnEraseBkgnd(WPARAM WParam,LPARAM LParam);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnSelChange(NMHDR * pNotifyStruct, LRESULT* result);
	afx_msg LRESULT OnLeftPaneSelChange(WPARAM WParam,LPARAM LParam);
	afx_msg void OnPaint();
};
